/*
 * @Author: nengwu 409791297@qq.com
 * @Date: 2020-07-01 23:46:46
 * @LastEditors: mylesshie@gmail.com
 * @LastEditTime: 2020-07-14 15:33:24
 * @description:
 */

import React from 'react'
import { View, Text, TouchableOpacity, Image } from 'react-native'
import { useNavigation } from '@react-navigation/native'
import styles from './styles'

const MessageItem = props => {
  const navigation = useNavigation()

  const _onPress = () => {
    if (props.articleId) {
      navigation.navigate('NewsDetail', {
        id: props.articleId
      })
    }
  }

  return (
    <TouchableOpacity onPress={_onPress}>
      <View style={styles.wrap}>
        <View style={styles.top}>
          <View style={styles.newsTitle}>
            <Text style={styles.newsTitleText} numberOfLines={1}>
              {props.title}
            </Text>
          </View>
          <View style={styles.date}>
            <Text style={styles.dateText} numberOfLines={1}>
              {props.date}
            </Text>
          </View>
        </View>
        <View style={styles.bottom}>
          <View style={styles.br}>
            <View style={styles.title}>
              <Text style={styles.titleText} numberOfLines={2}>
                {props.msg || props.articleTitle}
              </Text>
            </View>
          </View>
        </View>
      </View>
    </TouchableOpacity>
  )
}

export default MessageItem
